package com.qfedu.springmvc02.controller;

import com.qfedu.springmvc02.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhang
 * @Title: commonValidateAdd
 * @date : 2022/5/4 16:55
 */
@RestController
@RequestMapping("/json")
public class JsonController {

    @RequestMapping(value = "test1")
    public User test1(){
        User user = new User();
        user.setName("小高");
        user.setPassword("123");
        return user;
    }
    @GetMapping("test2")
    public User test2(){
        User user = new User();
        user.setName("小天2");
        user.setPassword("1111");
        return user;
    }

    @GetMapping({"test3","test4"})
    public User test3(){
        User user = new User();
        user.setName("小天3");
        user.setPassword("1111");
        return user;
    }

    @RequestMapping(value = "test5",produces = "text/html;charset=UTF-8")
    public String test5(){
        return "开心";
    }
    @RequestMapping(value = "test6")
    public User test6(@RequestBody User user){
        System.out.println("user = " + user);
        return user;
    }

}
